package com.tgit.sso.paltform.central.service.impl;

import com.tgit.sso.core.conf.SsoException;
import com.tgit.sso.paltform.central.entity.Product;
import com.tgit.sso.paltform.central.entity.ReqUserPwd;
import com.tgit.sso.paltform.central.entity.ReqUserRegister;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tgit.sso.paltform.central.entity.AccountInfo;
import com.tgit.sso.paltform.central.mapper.UserMapper;
import com.tgit.sso.paltform.central.service.UserService;

import java.util.List;

/**
 * 用户业务服务层-实现成
 * @author 范再军
 * 2018年9月13日
 */
@Service("userService")
public class UserServiceImpl implements UserService{
	@Autowired
	UserMapper userMapper;

	@Override
	public AccountInfo findByUsername(String userName) {
		return userMapper.findByUsername(userName);
	}

	@Override
	public List< Product > findProcutInfo(String nowTime) {
		return userMapper.findProdcutInfo(nowTime);
	}

	@Override
	public void registerUserInfo(ReqUserRegister req) {
		Integer count = userMapper.registerUserInfo(req);
		if(count==null || count==0){
			throw new SsoException("用户注册失败");
		}
	}

	@Override
	public void updateUserPwd(ReqUserPwd req,String pwd) {
		Integer count = userMapper.updateAuthpwd(req,pwd);
		if(count==null || count==0){
			throw new SsoException("用户密码修改失败");
		}
	}

	@Override
	public Integer findUserExists(String email,String userName) {
		return userMapper.findUserByEmail(email,userName);
	}

}
